#include <string.h>
#include <stdio.h>

/*
 * 识别对象及其结构		P173
 */

class Base
{
	public:
		void demo(void);
		int x;

	private:
		void demo_private(void);
		int y;
};

void Base::demo_private(void)
{
	printf("private.\n");
}

void Base::demo(void)
{
	printf("Base.\n");
	this->demo_private();
	this->y = 0x666;
}

int main()
{
	Base *base = new Base;

	base->demo();
	base->x = 0x777;
}

/*
	Base.
	private.
 */


#if 0
/*
 * intel
 */
000000000000116a <_ZN4Base12demo_privateEv>:
    116a:	f3 0f 1e fa          	endbr64 
    116e:	55                   	push   %rbp
    116f:	48 89 e5             	mov    %rsp,%rbp	// rbp=rsp
    1172:	48 83 ec 10          	sub    $0x10,%rsp	// rsp-=0x10
    1176:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// rbp-0x8=rdi
    117a:	48 8d 3d 83 0e 00 00 	lea    0xe83(%rip),%rdi        # 2004 <_IO_stdin_used+0x4>
    1181:	e8 ea fe ff ff       	callq  1070 <puts@plt>	// puts(rdi)
    1186:	90                   	nop
    1187:	c9                   	leaveq 
    1188:	c3                   	retq   
    1189:	90                   	nop

000000000000118a <_ZN4Base4demoEv>:
    118a:	f3 0f 1e fa          	endbr64 
    118e:	55                   	push   %rbp
    118f:	48 89 e5             	mov    %rsp,%rbp	// rbp=rsp
    1192:	48 83 ec 10          	sub    $0x10,%rsp	// rsp-=0x10
    1196:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// rbp-0x8=rdi
    119a:	48 8d 3d 6c 0e 00 00 	lea    0xe6c(%rip),%rdi        # 200d <_IO_stdin_used+0xd>
    11a1:	e8 ca fe ff ff       	callq  1070 <puts@plt>	// puts(rdi)
    11a6:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=rbp-0x8
    11aa:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    11ad:	e8 b8 ff ff ff       	callq  116a <_ZN4Base12demo_privateEv>	// demo(rdi)
    11b2:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=rbp-0x8
    11b6:	c7 40 04 66 06 00 00 	movl   $0x666,0x4(%rax)	// rax+4=0x666
    11bd:	90                   	nop
    11be:	c9                   	leaveq 
    11bf:	c3                   	retq   

00000000000011c0 <main>:
    11c0:	f3 0f 1e fa          	endbr64 
    11c4:	55                   	push   %rbp
    11c5:	48 89 e5             	mov    %rsp,%rbp	// rbp=rsp
    11c8:	48 83 ec 10          	sub    $0x10,%rsp	// rsp-=0x10
    11cc:	bf 08 00 00 00       	mov    $0x8,%edi	// edi=0x8
    11d1:	e8 8a fe ff ff       	callq  1060 <_Znwm@plt>	// new(8)
    11d6:	48 89 45 f8          	mov    %rax,-0x8(%rbp)	// rbp-0x8=rax
    11da:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=rbp-0x8
    11de:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    11e1:	e8 a4 ff ff ff       	callq  118a <_ZN4Base4demoEv> // demo()
    11e6:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=rbp-0x8
    11ea:	c7 00 77 07 00 00    	movl   $0x777,(%rax)	// rax=0x777
    11f0:	b8 00 00 00 00       	mov    $0x0,%eax	// eax=0
    11f5:	c9                   	leaveq 
    11f6:	c3                   	retq   
    11f7:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
    11fe:	00 00 

/*
 * arm
 */
00000000004006ac <_ZN4Base12demo_privateEv>:
  4006ac:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  4006b0:	910003fd 	mov	x29, sp
  4006b4:	f9000fa0 	str	x0, [x29, #24]
  4006b8:	90000000 	adrp	x0, 400000 <_init-0x528>
  4006bc:	911fc000 	add	x0, x0, #0x7f0
  4006c0:	97ffffb4 	bl	400590 <puts@plt>
  4006c4:	d503201f 	nop
  4006c8:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4006cc:	d65f03c0 	ret

00000000004006d0 <_ZN4Base4demoEv>:
  4006d0:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  4006d4:	910003fd 	mov	x29, sp
  4006d8:	f9000fa0 	str	x0, [x29, #24]
  4006dc:	90000000 	adrp	x0, 400000 <_init-0x528>
  4006e0:	91200000 	add	x0, x0, #0x800
  4006e4:	97ffffab 	bl	400590 <puts@plt>
  4006e8:	f9400fa0 	ldr	x0, [x29, #24]
  4006ec:	97fffff0 	bl	4006ac <_ZN4Base12demo_privateEv>	// demo(x0)
  4006f0:	f9400fa0 	ldr	x0, [x29, #24]				// x0=x29+24
  4006f4:	5280ccc1 	mov	w1, #0x666                 	// #1638
  4006f8:	b9000401 	str	w1, [x0, #4]
  4006fc:	d503201f 	nop
  400700:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400704:	d65f03c0 	ret

0000000000400708 <main>:
  400708:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  40070c:	910003fd 	mov	x29, sp
  400710:	d2800100 	mov	x0, #0x8                   	// #8
  400714:	97ffffa3 	bl	4005a0 <_Znwm@plt>	// new(8)
  400718:	f9000fa0 	str	x0, [x29, #24]		// x29+24=x0
  40071c:	f9400fa0 	ldr	x0, [x29, #24]		// x0=x29+24
  400720:	97ffffec 	bl	4006d0 <_ZN4Base4demoEv>	// demo
  400724:	f9400fa0 	ldr	x0, [x29, #24]		// x0=x29+24
  400728:	5280eee1 	mov	w1, #0x777              // #1911 w1=0x777
  40072c:	b9000001 	str	w1, [x0]		// [x0]=w1
  400730:	52800000 	mov	w0, #0x0                   	// #0
  400734:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400738:	d65f03c0 	ret
  40073c:	00000000 	.inst	0x00000000 ; undefined


 #endif
